extends Node

#检测在手机上的触摸按下、拖拽、抬手
#在一个节点脚本里写入如下代码

# Declare member variables here. Examples:
# var a = 2
# var b = "text"


# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#	pass

var touch_pos = Vector2.ZERO	# 触摸位置
var lift_up_pos = Vector2.ZERO	# 抬手位置
func _input(event: InputEvent) -> void:
	# 触摸按下
	if event is InputEventScreenTouch:
		touch_pos = event.position
	
	# 拖拽
	elif event is InputEventScreenDrag:
		lift_up_pos = event.position
	
	# 触摸抬起
	elif event is InputEventMouseButton:
		if touch_pos.distance_to(lift_up_pos) > 10:
			printt(touch_pos.distance_to(lift_up_pos),
				lift_up_pos, touch_pos
			)
		lift_up_pos = event.position
		touch_pos = event.position
